<?php

$client = new \Client\RpcClient();
//var_dump($client);
?>

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="Generator" content="EditPlus®">
    <meta name="Author" content="">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    <title>Rpc</title>
    <link rel="stylesheet" type="text/css" href="/css/buy.css">
</head>
<body>
<div class="banner"></div>
<div class="center">
    <ul>
        <?php
        $list = $client->service('GoodsService')->getList();

        $requestServer = explode('-', $list);
        //                var_dump($requestServer);
        $port = json_decode($requestServer[1], true);
//                         var_dump($port);
//                        var_dump($requestServer[0]);
        $client = new swoole_client(SWOOLE_SOCK_TCP);
        if (!$client->connect($requestServer[0],  $port['tcp'], -1))
        {
            exit("connect failed. Error: {$client->errCode}\n");
        }
        $client->send("hello world\n");
        echo $client->recv();
        $client->close();
//        $client = new \Swoole\Http\Client($requestServer[0], $port['tcp']);
//        $client->on('message', function ($cli, $frame) {
//                   var_dump($cli);
//        });
//        $client->upgrade('/', function ($cli) {
//            $cli->push('11');
//        });
        //        $client->close();
        /* if(!empty($list)){
             echo $list['data'];
         }*/
        ?>
    </ul>
</div>
<?php
//$cart=$client->service('CartService')->cart();
//echo $cart;
/*if(!empty($cart)){
    echo $cart['data'];
}*/
?>
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/buy.js"></script>
<script type="text/javascript" src="/js/sx_fly.js"></script>
</body>

</html>
